<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>联系小R客服</title>
    <link rel="stylesheet" href="../CSS/contact.css">
    <link rel="stylesheet" href="../CSS/style.css">
</head>
<body>
    <div class="header w">
        <div class="logo">
            <img src="../images/logo.png" width="120px" height="80px" alt="">
        </div>
        <div class="nav">
            <ul>
                <li><a href="../index.html">首页</a></li>
                <li><a href="./login.html">登录/注册</a></li>            
                <li><a href="./settlement.html">购物车</a></li>
                <li><a href="./shop.html">商城</a></li>
                <li><a href="./contact.html">联系客服</a></li>
                <li><a href="./service.html">售后</a></li>
            </ul>
        </div>
    </div>

    <div class="chat-container">
        <div class="chat-box" id="chat-box">
            <div class="chat-message received">欢迎来到小R图书，有什么可以帮助您？</div>
        </div>
        <input type="text" class="message-input" id="message-input" placeholder="输入消息...">
        <button class="send-button" onclick="sendMessage()">发送</button>
    </div>
    <div class="tool">
        <a href="./settlement.html" class="on tool-item1">购物车</a>
        <a href="./contact.html" class="tool-item2">联系<br>客服</a>
        <a href="./person.html" class="tool-item3">个人<br>资料</a>
        <a id="goTop" class="tool-item4" onclick="goTop()"><span class="top-arrow"></span>顶部</a>
        <a href="./service.html" class="tool-item5">反馈</a>
        <a href="../index.html" class="tool-item5">首页</a>
    </div>
    <script>
        function sendMessage() {
            var messageInput = document.getElementById('message-input');
            var chatBox = document.getElementById('chat-box');
            var userMessage = messageInput.value;
            var newMessage = document.createElement('div');
            newMessage.className = 'chat-message sent';
            newMessage.textContent = userMessage;
            chatBox.appendChild(newMessage);
            
            // 模拟机器人回复
            setTimeout(function() {
                var botReply = document.createElement('div');
                botReply.className = 'chat-message received';
                botReply.textContent = '亲！有什么需要帮助的（以上是机器人的回复）';
                chatBox.appendChild(botReply);
            }, 500); // 模拟1秒后机器人回复
    
            messageInput.value = ''; // 清空输入框
        }
    </script>
</body>
</html>